<template>
<!-- <Row v-loading="spinShow" class="layout-content-body"> -->
<dtable 
:columns="columns" :dataAll="dataAll" 
:dataShow="dataShow" :totals="totals" @sortOrder="sortOrder"
@delCheck="delCheck" @refresh="refresh()" 
@show="show" @changePage="changePage" @search="getall" 
@changeSize="changeSize" :loading="loading"></dtable>
<!-- </Row> -->
</template>

<script>
import dtable from "../../components/table/btable.vue";
export default {
  data() {
    return {
      loading: false,
      columns: [
        //多选框
        {
          type: "selection",
          width: 60,
          align: "center"
        },
        {
          title: "操作者",
          width: 120,
          key: "Creater",
          sortable: true
        },
        {
          title: "所属组织",
          width: 280,
          key: "OrgName",
          sortable: true
        },
        {
          title: "操作内容",
          width: 320,
          key: "Contect",
          sortable: true
        },
        {
          title: "操作日期",
          width: 320,
          key: "Ctime",
          sortable: true
        },
        {
          title: "操作IP",
          key: "Ip"
        }
      ],
      dataShow: true, //是否显示表格数据查看表单
      dataAll: [],
      editData: false,
      totals: 0,
      pagedata: {
        pagesize: 10,
        page: 1,
        searchKey: "",
        sortby: ["Ctime"],
        order: ["desc"]
      }
    };
  },
  components: {
    dtable
  },
  computed: {},
  watch: {},
  methods: {
    refresh() {
      this.getall(this.pagedata);
    },
    getall(pd) {
      this.loading = true;
      this.$api.getLog(pd).then(res => {
        if (!res.error) {
          this.dataAll = res.Data.data;
          this.totals = res.Data.total;
        } else {
          this.$Message.error(res.message);
        }
        this.loading = false;
      });
    },
    show(row) {
      this.showItem = row;
      this.showData = true;
    },
    delCheck(row) {
      console.log("sdsdsds", row);
      this.$api.deleteLogs(row).then(response => {
        if (!res.error) {
          this.getall();
          this.$Message.success(res.message);
        } else {
          this.$Message.error(res.message, 4);
        }
      });
    },
    //      改变页码大小
    changeSize(current) {
      this.pagedata.page = current;
      this.getall(this.pagedata);
    },
    //      改变页码
    changePage(current) {
      console.log(current);
      this.pagedata = current;
      this.getall(this.pagedata);
    },
    //      排序
    sortOrder(current) {
      console.log(current);
      this.pagedata = current;
      this.getall(this.pagedata);
    }
  },
  mounted() {
    this.getall(this.pagedata);
  }
};
</script>


